<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class promo extends CI_Controller {
	
	public function __construct() {
		parent::__construct();
		ini_set('session.cookie_httponly',1); 
		ini_set('session.use_only_cookies',1);
		$this->load->model('exchange_item_class');
	}	 
	
	public function save_exchange_item(){
		$post = $this->input->post();
		if(isset($post['intID'])){
			$message = $this->exchange_item_class->update($post);
		} else {
			$message = $this->exchange_item_class->insert($post);
		}
		echo json_encode($message);
	}
	public function exchange_item_list(){
		$data=array();
		
		$post = $this->input->post();	
		$exchange_item = $this->exchange_item_class->get_exchange_item($post);
		
		if($exchange_item!=0){
			foreach($exchange_item as $key=>$value){
				$data['intID'][$key]=$value['intID'];
				$data['strItemCode'][$key]=$value['strItemCode'];
				$data['strTitle'][$key]=$value['strTitle'];
				$data['strDescription'][$key]=$value['strDescription'];
				$data['intPoints'][$key]=$value['intPoints'];
				$data['dateStart'][$key]=$value['dateStart'];
				$data['dateEnd'][$key]=$value['dateEnd'];
				$data['intQty'][$key]=$value['intQty'];
			}
		}
		echo json_encode($data);
	}
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */